home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / omega / ocom2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-06  |  26.1 KB  |  1,075 lines

  1. /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988 */
  2. /* ocom2.c */
  3.  
  4. /* This file contains toplevel commands called from ocom1.c */
  5.  
  6. #include "oglob.h"
  7.  
  8.  
  9. /* no op a turn.... */
  10. void rest()
  11. {
  12.   if (random_range(20) == 1) {
  13.     switch(random_range(10)) {
  14.       case 0: print3(" Time passes slowly.... "); break;
  15.       case 1: print3(" Tick. Tock. Tick. Tock. "); break;
  16.       case 2: print3(" Ho Hum. "); break;
  17.       case 3: print3(" Beauty Sleep. Well, in your case, Ugly Sleep. "); break;
  18.       case 4: print3(" And with Strange Aeons, even Death may die. "); break;
  19.       case 5: print3(" La Di Da. "); break;
  20.       case 6: print3(" Time keeps on tickin' tickin' -- into the future.... ");
  21.             break;
  22.       case 7: print3(" Boooring! "); break;
  23.       case 8: print3(" You think I like watching you sleep? "); break;
  24.       case 9: print3(" You sure have an early bedtime! "); break;
  25.     }
  26.     morewait();
  27.   }
  28. }
  29.  
  30.  
  31. /* read a scroll, book, tome, etc. */
  32. void peruse()
  33. {
  34.   int index;
  35.   struct object *obj;
  36.  
  37.   clearmsg();
  38.  
  39.   if (Player.status[BLINDED] > 0)
  40.     print3("You're blind -- you can't read!!!");
  41.   else if (Player.status[AFRAID] > 0)
  42.     print3("You are too afraid to stop to read a scroll!");
  43.   else {
  44.     print1("Read -- ");
  45.     index = getitem(SCROLL);
  46.     if (index == ABORT)
  47.       setgamestatus(SKIP_MONSTERS);
  48.     else {
  49.       obj = Player.possessions[index];
  50.       if (obj->objchar != SCROLL) {
  51.     print3("There's nothing written on ");
  52.     nprint3(itemid(obj));
  53.       }
  54.       else {
  55.     nprint1("You carefully unfurl the scroll....");
  56.     morewait();
  57.     item_use(obj);
  58.     dispose_lost_objects(1,obj);
  59.       }
  60.     }
  61.   }
  62. }
  63.  
  64.  
  65.  
  66.  
  67. void quaff()
  68. {
  69.   int index;
  70.   struct object *obj;
  71.   clearmsg();
  72.   print1("Quaff --");
  73.   index = getitem(POTION);
  74.   if (index == ABORT)
  75.     setgamestatus(SKIP_MONSTERS);
  76.   else {
  77.     obj = Player.possessions[index];
  78.     if (obj->objchar != POTION) {
  79.       print3("You can't drink ");
  80.       nprint3(itemid(obj));
  81.     }
  82.     else {
  83.       print1("You drink it down.... ");
  84.       item_use(obj);
  85.       morewait();
  86.       dispose_lost_objects(1,obj);
  87.     }
  88.   }
  89. }
  90.  
  91.  
  92.  
  93.  
  94. void activate()
  95. {
  96.   int index;
  97.   char response;
  98.  
  99.   clearmsg();
  100.  
  101.   print1("Activate -- item [i] or artifact [a] or quit [ESCAPE]?");
  102.   do response = mcigetc();
  103.   while ((response != 'i') && (response != 'a') && (response != ESCAPE));
  104.   if (response != ESCAPE) {
  105.     if (response == 'i')
  106.       index = getitem(THING);
  107.     else if (response == 'a')
  108.       index = getitem(ARTIFACT);
  109.     if (index != ABORT) {
  110.       clearmsg();
  111.       print1("You activate it.... ");
  112.       morewait();
  113.       item_use(Player.possessions[index]);
  114.     }
  115.     else setgamestatus(SKIP_MONSTERS);
  116.   }
  117.   else setgamestatus(SKIP_MONSTERS);
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124. void eat()
  125. {
  126.   int index;
  127.   struct object *obj;
  128.  
  129.   clearmsg();
  130.  
  131.   print1("Eat --");
  132.   index = getitem(FOOD);
  133.   if (index == ABORT)
  134.     setgamestatus(SKIP_MONSTERS);
  135.   else {
  136.     obj = Player.possessions[index];
  137.     if ((obj->objchar != FOOD)&&(obj->objchar != CORPSE)) {
  138.       print3("You can't eat ");
  139.       nprint3(itemid(obj));
  140.     }
  141.     else {
  142.       if (obj->usef == I_FOOD) Player.food = max(0,Player.food+obj->aux);
  143.       item_use(obj);
  144.       dispose_lost_objects(1,obj);
  145.       if (Current_Dungeon == E_COUNTRYSIDE) {
  146.     Time += 100;
  147.     hourly_check();
  148.       }
  149.     }
  150.   }
  151.   foodcheck();
  152. }
  153.  
  154.  
  155.  
  156.  
  157. /* search all adjacent spots for secrecy */
  158. void search(searchval)
  159. int *searchval;
  160. {
  161.   int i;
  162.   if (Player.status[AFRAID] > 0)
  163.     print3("You are too terror-stricken to stop to search for anything.");
  164.   else {
  165.     if (!gamestatusp(FAST_MOVE)) {
  166.       setgamestatus(FAST_MOVE);
  167.       *searchval = Searchnum;
  168.     }
  169.     for (i=0;i<8;i++) 
  170.       searchat(Player.x+Dirs[0][i],Player.y+Dirs[1][i]);
  171.     drawvision(Player.x,Player.y);
  172.   }
  173. }
  174.  
  175.  
  176.  
  177. /* pick up a thing where the player is */
  178.  void pickup()
  179.  {
  180.    if (Level->site[Player.x][Player.y].things == NULL)
  181.      print3("There's nothing there!");
  182.    else pickup_at(Player.x,Player.y);
  183.  }
  184.  
  185.  
  186. /* floor inventory */
  187. void floor_inv()
  188. {
  189.   pol ol = Level->site[Player.x][Player.y].things;
  190.   setgamestatus(SKIP_MONSTERS);
  191.   menuclear();
  192.   while (ol != NULL) {
  193.     if (ol->thing == NULL) print3("***Error; null thing on things list***");
  194.     else {
  195.       menuprint(itemid(ol->thing));
  196.       menuprint("\n");
  197.     }
  198.     ol = ol->next;
  199.   }
  200.   morewait();
  201.   xredraw();
  202. }
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. void drop()
  213. {
  214.   int index,n;
  215.   
  216.   clearmsg();
  217.  
  218.   print1("Drop --");
  219.   index = getitem(CASHVALUE);
  220.   if (index == ABORT)
  221.     setgamestatus(SKIP_MONSTERS);
  222.   else {
  223.     if (index == CASHVALUE) drop_money();
  224.     else if ((! Player.possessions[index]->used) ||
  225.          (! cursed(Player.possessions[index]))) {
  226.       if (Player.possessions[index]->number == 1) {
  227.     p_drop_at(Player.x,Player.y,1,Player.possessions[index]);
  228.     conform_lost_objects(1,Player.possessions[index]);
  229.       }
  230.       else {
  231.     n = getnumber(Player.possessions[index]->number);
  232.     p_drop_at(Player.x,Player.y,n,Player.possessions[index]);
  233.     conform_lost_objects(n,Player.possessions[index]);
  234.       }
  235.     }
  236.     else {
  237.       print3("You can't seem to get rid of: ");
  238.       nprint3(itemid(Player.possessions[index]));
  239.     }
  240.   }
  241.   calc_melee();
  242. }
  243.  
  244.  
  245.       
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252. /* talk to the animals -- learn their languages.... */
  253. void talk()
  254. {
  255.   int dx,dy,index=0;
  256.   char response;
  257.   struct monster *m;
  258.  
  259.   clearmsg();
  260.  
  261.   print1("Talk --");
  262.   index = getdir();
  263.  
  264.   if (index == ABORT)
  265.     setgamestatus(SKIP_MONSTERS);
  266.   else {
  267.     dx = Dirs[0][index];
  268.     dy = Dirs[1][index];
  269.     
  270.     if ((! inbounds(Player.x+dx, Player.y+dy)) ||
  271.     (Level->site[Player.x+dx][Player.y+dy].creature == NULL)) {
  272.       print3("There's nothing there to talk to!!!");
  273.       setgamestatus(SKIP_MONSTERS);
  274.     }
  275.     else {
  276.       m = Level->site[Player.x+dx][Player.y+dy].creature;
  277.       menuclear();
  278.       strcpy(Str1,"     Talk to ");
  279.       strcat(Str1,m->monstring);
  280.       strcat(Str1,":");
  281.       menuprint(Str1);
  282.       menuprint("\na: Greet.");
  283.       menuprint("\nb: Threaten.");
  284.       menuprint("\nc: Surrender.");
  285.       menuprint("\nESCAPE: Clam up.");
  286.       do response = menugetc();
  287.       while ((response != 'a') &&
  288.          (response != 'b') &&
  289.          (response != 'c') &&
  290.          (response != ESCAPE));
  291.       switch(response) {
  292.       case 'a': monster_talk(m); break;
  293.       case 'b': threaten(m); break;
  294.       case 'c': surrender(m); break;
  295.       default: setgamestatus(SKIP_MONSTERS); break;
  296.       }
  297.     }
  298.   }
  299.   xredraw();
  300. }
  301.  
  302. /* try to deactivate a trap */
  303. void disarm()
  304. {
  305.   int x,y,index=0;
  306.   pob o;
  307.  
  308.   clearmsg();
  309.   print1("Disarm -- ");
  310.  
  311.   index = getdir();
  312.  
  313.   if (index == ABORT)
  314.     setgamestatus(SKIP_MONSTERS);
  315.   else {
  316.     x = Dirs[0][index]+Player.x;
  317.     y = Dirs[1][index]+Player.y;
  318.     
  319.     if (! inbounds(x,y))
  320.       print3("Whoa, off the map...");
  321.     else if (Level->site[x][y].locchar != TRAP)
  322.       print3("You can't see a trap there!");
  323.     else {
  324.       if (random_range(50+Level->depth*2) < 
  325.       Player.dex+Player.level+Player.rank[THIEVES]*10) {
  326.     print1("You disarmed the trap!");
  327.     if (random_range(100) < Player.dex+Player.rank[THIEVES]*10) {
  328.       o = ((pob) malloc(sizeof(objtype)));
  329.       switch(Level->site[x][y].p_locf) {
  330.       case L_TRAP_DART: 
  331.         *o=Objects[THINGID+17];
  332.         break;
  333.       case L_TRAP_DISINTEGRATE:
  334.         *o=Objects[THINGID+23];
  335.         break;
  336.       case L_TRAP_SLEEP_GAS:
  337.         *o=Objects[THINGID+22];
  338.         break;
  339.       case L_TRAP_TELEPORT:
  340.         *o=Objects[THINGID+21];
  341.         break;
  342.       case L_TRAP_ABYSS:
  343.         *o=Objects[THINGID+24];
  344.         break;
  345.       case L_TRAP_FIRE:
  346.         *o=Objects[THINGID+20];
  347.         break;
  348.       case L_TRAP_SNARE:
  349.         *o=Objects[THINGID+19];
  350.         break;
  351.       case L_TRAP_ACID:
  352.         *o=Objects[THINGID+18];
  353.         break;
  354.       case L_TRAP_MANADRAIN:
  355.         *o=Objects[THINGID+25];
  356.         break;
  357.       default:
  358.         o = NULL;
  359.         break;
  360.       }
  361.       if (o != NULL) {
  362.         print2("You manage to retrieve the trap components!");
  363.         Objects[o->id].known = 1;
  364.         o->known = 1;
  365.         gain_item(o);
  366.         gain_experience(25);
  367.       }
  368.     }
  369.     Level->site[x][y].p_locf = L_NO_OP;
  370.     Level->site[x][y].locchar = FLOOR;
  371.     gain_experience(5);
  372.       }
  373.       else if (random_range(10+Level->depth) > Player.dex) {
  374.     print1("You accidentally set off the trap!");
  375.     Player.x = x; Player.y = y;
  376.     p_movefunction(Level->site[x][y].p_locf);
  377.       }
  378.       else print1("You failed to disarm the trap.");
  379.     }
  380.   }
  381. }
  382.  
  383. /* is it more blessed to give, or receive? */
  384. void give()
  385. {
  386.   int index;
  387.   int dx,dy,dindex=0;
  388.   struct monster *m;
  389.   pob obj;
  390.  
  391.   clearmsg();
  392.  
  393.   print1("Give to monster --");
  394.   dindex = getdir();
  395.   if (dindex == ABORT) 
  396.     setgamestatus(SKIP_MONSTERS);
  397.   else {
  398.     dx = Dirs[0][dindex];
  399.     dy = Dirs[1][dindex];
  400.     if (! inbounds(Player.x+dx, Player.y+dy))
  401.       print3("Whoa, off the map...");
  402.     else if (Level->site[Player.x+dx][Player.y+dy].creature == NULL) {
  403.       print3("There's nothing there to give something to!!!");
  404.       setgamestatus(SKIP_MONSTERS);
  405.     }
  406.     else {
  407.       m = Level->site[Player.x+dx][Player.y+dy].creature;
  408.       clearmsg();
  409.       print1("Give what? "); 
  410.       index = getitem(CASHVALUE);
  411.       if (index == ABORT)
  412.     setgamestatus(SKIP_MONSTERS);
  413.       else if (index == CASHVALUE) give_money(m);
  414.       else if (! cursed(Player.possessions[index])) {
  415.     obj = ((pob) malloc(sizeof(objtype)));
  416.     *obj = *(Player.possessions[index]);
  417.     conform_lost_objects(1,Player.possessions[index]);
  418.     obj->number = 1;
  419.     givemonster(m,obj);
  420.     print2("Given: ");
  421.     nprint2(itemid(obj));
  422.     morewait();
  423.     calc_melee();
  424.       }
  425.       else {
  426.     print3("You can't even give away: ");
  427.     nprint3(itemid(Player.possessions[index]));
  428.       }
  429.     }
  430.   }
  431. }
  432.  
  433.  
  434.  
  435.  
  436. /* zap a wand, of course */
  437. void zapwand()
  438. {
  439.   int index;
  440.   struct object *obj;
  441.  
  442.   clearmsg();
  443.  
  444.   if (Player.status[AFRAID] > 0)
  445.     print3("You are so terror-stricken you can't hold a wand straight!");
  446.   else {
  447.     print1("Zap --");
  448.     index = getitem(STICK);
  449.     if (index == ABORT)
  450.       setgamestatus(SKIP_MONSTERS);
  451.     else {
  452.       obj = Player.possessions[index];
  453.       if (obj->objchar != STICK) {
  454.     print3("You can't zap: ");
  455.     nprint3(itemid(obj));
  456.       }
  457.       else 
  458.     if (obj->charge < 1) 
  459.       print3("Fizz.... Pflpt. Out of charges. ");
  460.     else {
  461.       obj->charge--;
  462.       item_use(obj);
  463.     }
  464.     }
  465.   }
  466. }
  467.  
  468. /* cast a spell */
  469. void magic()
  470. {
  471.   int index,drain;
  472.   clearmsg();
  473.   if (Player.status[AFRAID] > 0)
  474.     print3("You are too afraid to concentrate on a spell!");
  475.   else {
  476.     index = getspell();
  477.     xredraw();
  478.     if (index == ABORT)
  479.       setgamestatus(SKIP_MONSTERS);
  480.     else {
  481.       drain = Spells[index].powerdrain;
  482.       if (Lunarity == 1) drain = drain / 2;
  483.       else if (Lunarity == -1) drain = drain *2;
  484.       if (drain > Player.mana)
  485.     print3("You lack the power for that spell! ");
  486.       else {
  487.     Player.mana -= drain;
  488.     cast_spell(index);
  489.       }
  490.     }
  491.   }
  492.   dataprint();
  493. }
  494.  
  495.  
  496. /* go upstairs ('<' command) */
  497. void upstairs()
  498. {
  499.   if (Level->site[Player.x][Player.y].locchar != UP)
  500.     print3("Not here!");
  501.   else {
  502.     if (gamestatusp(MOUNTED))
  503.       print2("You manage to get your horse upstairs.");
  504.     print1("You ascend a level.");
  505.     if (Level->depth <= 1) {
  506.       if (Level->environment == E_SEWERS)
  507.     change_environment(E_CITY);
  508.       else change_environment(E_COUNTRYSIDE);
  509.     }
  510.     else change_level(Level->depth,Level->depth-1,FALSE);
  511.     roomcheck();
  512.   }
  513.   setgamestatus(SKIP_MONSTERS);
  514. }
  515.  
  516.  
  517.  
  518. /* go downstairs ('>' command) */
  519. void downstairs()
  520. {
  521.   if (Level->site[Player.x][Player.y].locchar != DOWN)
  522.     print3("Not here!");
  523.   else {
  524.     if (gamestatusp(MOUNTED))
  525.       print2("You manage to get your horse downstairs.");
  526.     if (Current_Environment == Current_Dungeon) {
  527.       print1("You descend a level.");
  528.       change_level(Level->depth,Level->depth+1,FALSE);
  529.       roomcheck();
  530.     }
  531.     else if ((Current_Environment == E_CITY) ||
  532.          (Last_Environment == E_CITY))
  533.       change_environment(E_SEWERS);
  534.     else if (Current_Environment != Current_Dungeon)
  535.       print3("This stairway is deviant. You can't use it.");
  536.   }
  537.   setgamestatus(SKIP_MONSTERS);
  538. }
  539.  
  540.  
  541.  
  542.  
  543. /* set various player options */
  544. /* have to redefine in odefs for next full recompile */
  545. void setoptions()
  546. {
  547.   int slot = 1,done = FALSE;
  548.   char response;
  549.  
  550.   clearmsg();
  551.   menuclear();
  552.  
  553.   display_options();
  554.  
  555.   move_slot(1,1,NUMOPTIONS);
  556.   clearmsg();
  557.   print1("Currently selected option is preceded by highlit >>");
  558.   print2("Move selected option with '>' and '<', ESCAPE to quit.");
  559.   do {
  560.     response = mcigetc();
  561.     switch(response) {
  562.     case 'j':
  563.     case '>':
  564.       slot = move_slot(slot,slot+1,NUMOPTIONS+1);
  565.       break;
  566.     case 'k':
  567.     case '<':
  568.       if (slot > 1) /* hack hack */
  569.     slot = move_slot(slot,slot-1,NUMOPTIONS+1); 
  570.       break;
  571.     case 't':
  572.       if (slot <= NUMTFOPTIONS) 
  573.     optionset(pow2(slot-1));
  574.       else if (slot == VERBOSITY_LEVEL)
  575.     Verbosity = TERSE;
  576.       else print3("'T' is meaningless for this option.");
  577.       break;
  578.     case 'f':
  579.       if (slot <= NUMTFOPTIONS) 
  580.     optionreset(pow2(slot-1));
  581.       else print3("'F' is meaningless for this option.");
  582.       break;
  583.     case 'm':
  584.       if (slot == VERBOSITY_LEVEL) 
  585.     Verbosity = MEDIUM;
  586.       else print3("'M' is meaningless for this option.");
  587.       break;
  588.     case 'v':
  589.       if (slot == VERBOSITY_LEVEL) 
  590.     Verbosity = VERBOSE;
  591.       else print3("'V' is meaningless for this option.");
  592.       break;
  593.     case '1':case '2':case '3':case '4':case '5':
  594.     case '6':case '7':case '8':case'9':
  595.       if (slot == SEARCH_DURATION)
  596.     Searchnum = response - '0';
  597.       else print3("A number is meaningless for this option.");
  598.       break;
  599.     case ESCAPE:
  600.       done = TRUE;
  601.       break;
  602.     default: print3("That response is meaningless for this option."); break;
  603.     }
  604.     display_option_slot(slot);
  605.     move_slot(slot,slot,NUMOPTIONS+1);
  606.   } while (! done);
  607.   xredraw();
  608. }
  609.  
  610.  
  611.  
  612. /* name an item */
  613. void callitem()
  614. {
  615.   int index;
  616.   pob obj;
  617.  
  618.   clearmsg();
  619.   setgamestatus(SKIP_MONSTERS);
  620.   print1("Call --");
  621.   index = getitem(NULL);
  622.   if (index == CASHVALUE) print3("Can't rename cash!");
  623.   else if (index != ABORT) {
  624.     obj = Player.possessions[index];
  625.     if (obj->known)
  626.       print3("That item is already identified!");
  627.     else {
  628.       print1("Call it:");
  629.       obj->objstr = salloc(msgscanstring());
  630.       clearmsg();
  631.       print2("Also call by that name all similar items? [yn] ");
  632.       if (ynq2() == 'y') {
  633.     Objects[obj->id].objstr = salloc(obj->objstr);
  634.       }
  635.     }
  636.   }
  637. }
  638.       
  639.  
  640.  
  641.  
  642. /* open a door */
  643. void opendoor()
  644. {
  645.   int dir;
  646.   int ox,oy;
  647.  
  648.   clearmsg();
  649.   print1("Open --");
  650.   dir = getdir();
  651.   if (dir == ABORT)
  652.     setgamestatus(SKIP_MONSTERS);
  653.   else {
  654.     ox = Player.x + Dirs[0][dir];
  655.     oy = Player.y + Dirs[1][dir];
  656.     if (Level->site[ox][oy].locchar == OPEN_DOOR) {
  657.       print3("That door is already open!");
  658.       setgamestatus(SKIP_MONSTERS);
  659.     }
  660.     else if (Level->site[ox][oy].locchar == PORTCULLIS) {
  661.       print1("You try to lift the massive steel portcullis....");
  662.       if (random_range(100) < Player.str) {
  663.     print2("Incredible. You bust a gut and lift the portcullis.");
  664.     Level->site[ox][oy].locchar = FLOOR;
  665.       }
  666.       else {
  667.     print2("Argh. You ruptured yourself.");
  668.     p_damage(Player.str,UNSTOPPABLE,"a portcullis");
  669.       }
  670.     }
  671.     else if ((Level->site[ox][oy].locchar != CLOSED_DOOR) || 
  672.          loc_statusp(ox,oy,SECRET)) {
  673.       print3("You can't open that!");
  674.       setgamestatus(SKIP_MONSTERS);
  675.     }
  676.     else if (Level->site[ox][oy].aux == LOCKED) 
  677.       print3("That door seems to be locked.");
  678.     else Level->site[ox][oy].locchar = OPEN_DOOR;
  679.   }
  680. }
  681.  
  682.  
  683.  
  684. /* Try to destroy some location */
  685. void bash_location()
  686. {
  687.   int dir;
  688.   int ox,oy;
  689.  
  690.   clearmsg();
  691.   print1("Bashing --");
  692.   dir = getdir();
  693.   if (dir == ABORT)
  694.     setgamestatus(SKIP_MONSTERS);
  695.   else {
  696.     ox = Player.x + Dirs[0][dir];
  697.     oy = Player.y + Dirs[1][dir];
  698.     if ((Current_Environment == E_CITY) &&
  699.     (ox == 0) &&
  700.     (oy == 0)) {
  701.       print1("Back Door WIZARD Mode!");
  702.       print2("You will invalidate your score if you proceed.");
  703.       morewait();
  704.       print1("Enable WIZARD Mode? [yn] ");
  705.       if (ynq1()=='y') {
  706.     print2("You feel like a cheater.");
  707.     setgamestatus(CHEATED);
  708.       }
  709.       else print2("A sudden tension goes out of the air....");
  710.     }
  711.     else {
  712.       if (Level->site[ox][oy].locchar == WALL) {
  713.     print1("You hurl yourself at the wall!");
  714.     p_damage(Player.str,NORMAL_DAMAGE,"a suicidal urge");
  715.       }
  716.       else if (Level->site[ox][oy].locchar == OPEN_DOOR) {
  717.     print1("You hurl yourself through the open door!");
  718.     print2("Yaaaaah! ... thud.");
  719.     Player.x = ox;
  720.     Player.y = oy;
  721.     p_damage(3,UNSTOPPABLE,"silliness");
  722.     p_movefunction(Level->site[Player.x][Player.y].p_locf);
  723.     setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
  724.       }
  725.       else if (Level->site[ox][oy].locchar == CLOSED_DOOR) {
  726.     if (loc_statusp(ox,oy,SECRET)) {
  727.       print1("You found a secret door!");
  728.       lreset(ox,oy,SECRET);
  729.     }
  730.     if (Level->site[ox][oy].aux == LOCKED) {
  731.       if (random_range(100)+Level->depth < Player.str) {
  732.         Player.x = ox;
  733.         Player.y = oy;
  734.         print1("You blast the door off its hinges!");
  735.         p_movefunction(Level->site[Player.x][Player.y].p_locf);
  736.         Level->site[ox][oy].locchar = FLOOR;
  737.         setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
  738.       }
  739.       else {
  740.         print1("Crash! The door holds.");
  741.         if (random_range(30) > Player.str)
  742.           p_damage(max(1,statmod(Player.str)),UNSTOPPABLE,"a door");
  743.       }
  744.     }
  745.     else {
  746.       Player.x = ox;
  747.       Player.y = oy;
  748.       print1("You bash open the door!");
  749.       if (random_range(30) > Player.str)
  750.         p_damage(1,UNSTOPPABLE,"a door");
  751.       p_movefunction(Level->site[Player.x][Player.y].p_locf);
  752.       Level->site[ox][oy].locchar = OPEN_DOOR;
  753.       setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
  754.     }
  755.       }
  756.       else if (Level->site[ox][oy].locchar == STATUE) {
  757.     statue_random(ox,oy);
  758.       }
  759.       else if (Level->site[ox][oy].locchar == PORTCULLIS) {
  760.     print1("Really, you don't have a prayer.");
  761.     if (random_range(1000) < Player.str) {
  762.       print2("The portcullis flies backwards into a thousand fragments.");
  763.       print3("Wow. What a stud.");
  764.       gain_experience(100);
  765.       Level->site[ox][oy].locchar = FLOOR;
  766.       Level->site[ox][oy].p_locf = L_NO_OP;
  767.     }
  768.     else {
  769.       print2("You only hurt yourself on the 3'' thick steel bars.");
  770.       p_damage(Player.str,UNSTOPPABLE,"a portcullis");
  771.     }
  772.       }
  773.       else if (Level->site[ox][oy].locchar == ALTAR) {
  774.     if ((Player.patron > 0)&&(Level->site[ox][oy].aux == Player.patron)) {
  775.       print1("You have a vision! An awesome angel hovers over the altar.");
  776.       print2("The angel says: 'You twit, don't bash your own altar!'");
  777.       print3("The angel slaps you upside the head for your presumption.");
  778.       p_damage(Player.hp-1,UNSTOPPABLE,"an annoyed angel");
  779.     }
  780.     else if (Level->site[ox][oy].aux == 0) {
  781.       print1("The feeble powers of the minor godling are not enough to");
  782.       print2("protect his altar! The altar crumbles away to dust.");
  783.       print3("You feel almost unbearably smug.");
  784.       Level->site[ox][oy].locchar = RUBBLE;
  785.       Level->site[ox][oy].p_locf = L_RUBBLE;
  786.       gain_experience(5);
  787.     }
  788.     else {
  789.       print1("You have successfully annoyed a major deity. Good job.");
  790.       print2("Zzzzap! A bolt of godsfire strikes!");
  791.       if (Player.rank[PRIESTHOOD] > 0) 
  792.         print3("Your own deity's aegis defends you from the bolt!");
  793.       p_damage(max(0,random_range(100)-Player.rank[PRIESTHOOD]*20),
  794.            UNSTOPPABLE,
  795.            "a bolt of godsfire");
  796.       if (Player.rank[PRIESTHOOD]*20+Player.pow+Player.level >
  797.           random_range(200)) {
  798.         morewait();
  799.         print1("The altar crumbles...");
  800.         Level->site[ox][oy].locchar = RUBBLE;
  801.         Level->site[ox][oy].p_locf = L_RUBBLE;
  802.         morewait();
  803.         print2("You sense your deity's pleasure with you.");
  804.         morewait();
  805.         print3("You are surrounded by a golden glow.");
  806.         cleanse(1);
  807.         heal(10);
  808.         gain_experience(500);
  809.       }
  810.     }
  811.       }
  812.       else {
  813.     print3("You restrain yourself from total silliness.");
  814.     setgamestatus(SKIP_MONSTERS);
  815.       }
  816.     }
  817.   }
  818. }
  819.  
  820.  
  821. /* attempt destroy an item */
  822. void bash_item()
  823. {
  824.   int item;
  825.   pob obj;
  826.  
  827.   clearmsg();
  828.   print1("Destroy an item --");
  829.   item = getitem(NULL);
  830.   if (item == CASHVALUE) print3("Can't destroy cash!");
  831.   else if (item != ABORT) {
  832.     obj = Player.possessions[item];
  833.     if (Player.str+random_range(20) > obj->fragility+random_range(20)) {
  834.       if (Player.alignment < 0) {
  835.     print2("That was fun....");
  836.     gain_experience(obj->level * obj->level * 5);
  837.       }
  838.       damage_item(obj);
  839.     }
  840.     else {
  841.       if (obj->objchar == WEAPON) {
  842.     print2("The weapon turned in your hand -- you hit yourself!");
  843.     p_damage(random_range(obj->dmg+abs(obj->plus)),
  844.          NORMAL_DAMAGE,
  845.          "a failure at vandalism");
  846.       }
  847.       else if (obj->objchar == ARTIFACT) {
  848.     print2("Uh Oh -- Now you've gotten it angry....");
  849.     p_damage(obj->level*10,
  850.          UNSTOPPABLE,
  851.          "an enraged artifact");
  852.       }
  853.       else {
  854.     print2("Ouch! Damn thing refuses to break...");
  855.     p_damage(1,UNSTOPPABLE,"a failure at vandalism");
  856.       }
  857.     }
  858.   }
  859. }
  860.  
  861.  
  862. /* guess what this does */
  863. void save(compress)
  864. int compress;
  865. {
  866.   clearmsg();
  867.   print1("Confirm Save? [yn] ");
  868.   if (ynq1() == 'y') {
  869.     if (gamestatusp(ARENA_MODE)) {
  870.       print3("Can't save the game in the arena!");
  871.       setgamestatus(SKIP_MONSTERS);
  872.     }
  873.     else if (Current_Environment == L_ADEPT) {
  874.       print3("Can't save the game in the Adept's Challenge!");
  875.       setgamestatus(SKIP_MONSTERS);
  876.     }
  877.     else {
  878.       print1("Enter savefile name: ");
  879.       strcpy(Str1,msgscanstring());
  880. #ifdef COMPRESS_SAVE_FILES
  881.       if (!compress) {
  882.     print1("Warning: This file will not be compressed.");
  883.     print2("You should compress it yourself.");
  884.     morewait();
  885.       }
  886. #endif
  887.       if (save_game(compress,Str1)) {
  888.     print3("Bye!");
  889.     sleep(1);
  890.     endgraf();
  891.     exit(0);
  892.       }
  893.       else setgamestatus(SKIP_MONSTERS);
  894.     }
  895.   }
  896.   else print1("Save Aborted.");
  897. }
  898.  
  899. /* close a door */
  900. void closedoor()
  901. {
  902.   int dir;
  903.   int ox,oy;
  904.  
  905.   clearmsg();
  906.  
  907.   print1("Close --");
  908.   dir = getdir();
  909.   if (dir == ABORT)
  910.     setgamestatus(SKIP_MONSTERS);
  911.   else {
  912.     ox = Player.x + Dirs[0][dir];
  913.     oy = Player.y + Dirs[1][dir];
  914.     if (Level->site[ox][oy].locchar == CLOSED_DOOR) {
  915.       print3("That door is already closed!");
  916.       setgamestatus(SKIP_MONSTERS);
  917.     }
  918.     else if (Level->site[ox][oy].locchar != OPEN_DOOR) {
  919.       print3("You can't close that!");
  920.       setgamestatus(SKIP_MONSTERS);
  921.     }
  922.     else Level->site[ox][oy].locchar = CLOSED_DOOR;
  923.   }
  924. }
  925.  
  926. /* handle a h,j,k,l, etc. */
  927. void moveplayer(dx,dy)
  928. int dx,dy;
  929. {
  930.   static int twiddle = FALSE;
  931.   if (p_moveable(Player.x+dx,Player.y+dy)) {
  932.       
  933.     if (Player.status[IMMOBILE] > 0) {
  934.       resetgamestatus(FAST_MOVE);
  935.       print3("You are unable to move");
  936.     }
  937.     else if ((Player.maxweight < Player.itemweight) && 
  938.          random_range(2) &&
  939.          (! Player.status[LEVITATING])) {
  940.       if (gamestatusp(MOUNTED)) {
  941.     print1("Your horse refuses to carry you and your pack another step!");
  942.     print2("Your steed bucks wildly and throws you off!");
  943.     p_damage(10,UNSTOPPABLE,"a cruelly abused horse");
  944.     resetgamestatus(MOUNTED);
  945.     summon(-1,HORSE);
  946.       }
  947.       else {
  948.     p_damage(1,UNSTOPPABLE,"a rupture");
  949.     print3("The weight of your pack drags you down. You can't move.");
  950.       }
  951.     }
  952.     else {
  953.       Player.x += dx;
  954.       Player.y += dy;
  955.       p_movefunction(Level->site[Player.x][Player.y].p_locf);
  956.       
  957.       /* causes moves to take effectively 30 seconds in town without
  958.          monsters being sped up compared to player */
  959.       if ((Current_Environment == E_CITY) ||
  960.       (Current_Environment == E_VILLAGE)) {
  961.     twiddle = ! twiddle;
  962.     if (twiddle) {
  963.       Time++;
  964.       if (Time % 10 == 0) tenminute_check();
  965.       else minute_status_check();
  966.     }
  967.       }
  968.  
  969.       /* this test protects against player entering countryside and still
  970.       having effects from being on the Level, a kluge, but hey,... */
  971.  
  972.       if (Current_Environment != E_COUNTRYSIDE) {
  973.     if (gamestatusp(FAST_MOVE))
  974.       if ((Level->site[Player.x][Player.y].things != NULL) ||
  975.           (optionp(RUNSTOP) && 
  976.            loc_statusp(Player.x,Player.y,STOPS)))
  977.         resetgamestatus(FAST_MOVE);
  978.     if ((Level->site[Player.x][Player.y].things != NULL) &&
  979.         (optionp(PICKUP)))
  980.       pickup();
  981.       }
  982.     }
  983.   }
  984.   else if (gamestatusp(FAST_MOVE)) {
  985.     drawvision(Player.x,Player.y);
  986.     resetgamestatus(FAST_MOVE);
  987.   }
  988. }
  989.  
  990.  
  991. /* handle a h,j,k,l, etc. */
  992. void movepincountry(dx,dy)
  993. int dx,dy;
  994. {
  995.   int i,takestime = TRUE;
  996.   if ((Player.maxweight < Player.itemweight) && 
  997.       random_range(2) &&
  998.       (! Player.status[LEVITATING])) {
  999.     if (gamestatusp(MOUNTED)) {
  1000.       print1("Your horse refuses to carry you and your pack another step!");
  1001.       print2("Your steed bucks wildly and throws you off!");
  1002.       p_damage(10,UNSTOPPABLE,"a cruelly abused horse");
  1003.       resetgamestatus(MOUNTED);
  1004.       morewait();
  1005.       print1("With a shrill neigh of defiance, your former steed gallops");
  1006.       print2("off into the middle distance....");
  1007.       if (Player.packptr != 0) {
  1008.     morewait();
  1009.     print1("You remember (too late) that the contents of your pack");
  1010.     print2("were kept in your steed's saddlebags!");
  1011.     for(i=0;i<MAXPACK;i++) {
  1012.       if (Player.pack[i] != NULL)
  1013.         free((char *) Player.pack[i]);
  1014.       Player.pack[i] = NULL;
  1015.     }
  1016.     Player.packptr = 0;
  1017.     calc_melee();
  1018.       }
  1019.     }
  1020.     else {
  1021.       p_damage(1,UNSTOPPABLE,"a rupture");
  1022.       print3("The weight of your pack drags you down. You can't move.");
  1023.     }
  1024.   }
  1025.   else {
  1026.     if (gamestatusp(LOST)) {
  1027.       print3("Being lost, you strike out randomly....");
  1028.       morewait();
  1029.       dx = random_range(3)-1;
  1030.       dy = random_range(3)-1;
  1031.     }
  1032.     if (p_country_moveable(Player.x+dx,Player.y+dy)) {
  1033.       if (Player.status[IMMOBILE] > 0) 
  1034.     print3("You are unable to move");
  1035.       else {
  1036.     Player.x += dx;
  1037.     Player.y += dy;
  1038.     if ((! gamestatusp(MOUNTED))&&(Player.possessions[O_BOOTS] != NULL)) {
  1039.       if (Player.possessions[O_BOOTS]->usef == I_BOOTS_7LEAGUE) {
  1040.         takestime = FALSE;
  1041.         if (Player.possessions[O_BOOTS]->blessing < 0) {
  1042.           print1("Whooah! -- Your boots launch you into the sky....");
  1043.           print2("You come down in a strange location....");
  1044.           Player.x = random_range(WIDTH);
  1045.           Player.y = random_range(LENGTH);
  1046.           morewait();
  1047.           clearmsg();
  1048.           print1("Your boots disintegrate with a malicious giggle...");
  1049.           dispose_lost_objects(1,Player.possessions[O_BOOTS]);
  1050.         }
  1051.         else if (Player.possessions[O_BOOTS]->known != 2) {
  1052.           print1("Wow! Your boots take you 7 leagues in a single stride!");
  1053.           Player.possessions[O_BOOTS]->known = 2;
  1054.         }
  1055.       }
  1056.     }
  1057.     if (gamestatusp(LOST) && (Precipitation < 1) && 
  1058.         Country[Player.x][Player.y].explored) {
  1059.       print3("Ah! Now you know where you are!");
  1060.       morewait();
  1061.       resetgamestatus(LOST);
  1062.     }
  1063.     else if (gamestatusp(LOST)) {
  1064.       print3("You're still lost.");
  1065.       morewait();
  1066.     }
  1067.     if (Precipitation > 0) Precipitation--;
  1068.     Country[Player.x][Player.y].explored = TRUE;
  1069.     terrain_check(takestime);
  1070.       }
  1071.     }
  1072.   }
  1073. }
  1074.  
  1075.